/***********************************************************
 * author: wuzhong
 * create: 2022-09-05
 * email：419479707@qq.com
 * source:
 * board:esp8266 core for arduino v3.0.2
 ***********************************************************/
 
#ifndef _HELPER_H
#define _HELPER_H

#include "Base64.h"
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <PubSubClient.h>      // 版本2.8.0
#include <ArduinoJson.h>       // 版本6.19.1
#include <ESP8266HTTPUpdateServer.h>

extern WiFiClient wifiClient;
extern PubSubClient mqttClient;
extern ESP8266WebServer server;

extern int wifiOpen;           // WIFI开关
extern char *wifiSsid;         // WIFI的SSID
extern char *wifiPwd;          // WIFI的密码
extern int mqttOpen;           // Mqtt服务器开关
extern char *mqttHost;         // Mqtt消息服务器地址
extern int mqttPort;           // Mqtt消息服务器端口
extern char *mqttUserName;     // Mqtt消息服务器账号
extern char *mqttUserPassport;  // Mqtt消息服务器密码
extern char *deviceIdentification; //设备标识
extern char *deviceTopic;       //设备上报数据队列

// 创建WEB服务
void createAPAndWebServer();
void handle_OnConnect();
void handle_DhtConfig();
void handle_NotFound();
String SendHTML();
// 连接wifi
void connectWifi();
String connectWifi(const char *ssid, const char *pwd);
// 连接mqtt
void connectMqtt();
String connectMqtt(const char *host, int port, const char *identification, const char *userName, const char *userPassport);

//打印提示信息
void printMsg(String tips);

#endif 
